{include file="common/header" /}
<div class="layui-fluid">
    <form class="layui-form layui-form-pane"  style="margin-top: 15px;">
        {eq name='type' value='update'}
        <input type="hidden" name="adid" value="{$id}"/>
        {/eq}
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">

                <input type="text" name="adname" placeholder="请输入用户名" autocomplete="off" class="layui-input" {eq name='type' value='update' }value="{$info.adname}" {/eq}>

            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">角色</label>
            <div class="layui-input-block">
                <select name="rid">
                    <option value="">请选择角色</option>
                    {volist name='role' id='v'}
                        <option value="{$v.roleid}" {if condition="($type eq 'update') && ($info['rid'] eq $v['roleid'])"}selected{/if}>{$v.rolename}</option>
                    {/volist}

                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">{eq name='type' value='add'}密码{else/}修改密码{/eq}</label>
            <div class="layui-input-block">
                <input type="password" name="password" placeholder="{eq name='type' value='add' }请填写密码{else /}要修改的密码{/eq}" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" {if
                       condition="($type eq 'add') || (($type eq 'update') && ($info['status'] eq 1))" }checked{/if}
                lay-skin="switch" lay-text="正常|禁用">
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <button class="layui-btn" lay-submit lay-filter="sub">立即提交</button>
            </div>
        </div>
    </form>
</div>
<script>
    //Demo
    layui.use(['form', 'jquery', 'layer'], function () {
        var form = layui.form,
            $ = layui.jquery,
            layer = layui.layer;

        //监听提交
        form.on('submit(sub)', function (data) {
            data.field.status = (data.field.status == 'on') ? 1 : 0;
            $.post('{:url("User/Save")}', data.field, function (e) {
                layer.msg(e.msg);

                if (e.status == 200) {
                    window.setTimeout(function () {
                        parent.reload(2);
                        parent.layer.closeAll();
                    }, 500);
                }
            },'json');
            return false;
        });
    });
</script>
{include file="common/footer" /}